class Solution(object):
    def longestSubstring(self, s, k):
        if len(s) < k:
            return 0
        for c in set(s):
            if s.count(c) < k:
                # max 函数的参数本质是个迭代器
                return max(self.longestSubstring(t, k) for t in s.split(c))
        return len(s)

